home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 3
/
ct-rom iiib.zip
/
ct-rom iiib
/
OS2
/
PROGRAM
/
LIFE2
/
LIFE2.DOC
< prev
next >
Wrap
Text File
|
1993-09-05
|
4KB
|
115 lines
Life2 - John Horton Conway's cellular simulation as implemented by
Charles Petzold in his book "Programming the OS/2 Presentation
Manager" with a number of enhancements by me, Larry Nomer.
The LIFE Simulation
-------------------
Start with a pattern of cells on a square grid. Each generation a new
cell will be "born" in any empty square bordering (horiz, vertically, or
diagonally) on exactly three other cells. Existing cells with one or no
neighbors will die of "exposure". Existing cells with four or more
neighbors will die of "overcrowding".
A number of interesting cell patterns have been discovered. They are shown
below along with a name. Try then!
Stable patterns: Block: x x Pond x x Blinker: x
x x x x x
x x x
(Note: The cells in "Block" above are all right next to each other.
A horizontal space between the "x"s has been inserted in all of
diagrams here for readability.)
Super "fertile": x x (Lack of vertical or horizontal symmetry often
x x has more interesting results.)
x
Glider: x (Repeats its same shape every fourth generation but
x shifted over one and down one. i.e. It travels
x x x across the screen at a 45 degree angle.
Spaceship: x x (Travels straight vertically or horizontally at
x a rate of two squares in four generations.)
x x (Note: I found this pattern by watching a
x x x x randomly generated grid. However, I am sure
it must have been included in the various
Scientific American articles on Life.)
Enhancements to Petzold's program
---------------------------------
First, let me say that Charles Petzold is a super programmer and he has
implemented the basic Life program very elegantly and efficiently. I am
a mere average "journeyman" programmer working to get better at OS/2
Presentation Manager programming.
o Upgrade to 2.x. Code upgraded from OS/2 1.3 (or 1.2) to OS/2 2.x
o Random. Added "Random" function to fill the grid randomly with X % cells.
o Drawing. If you hold mouse button 1 down then you will draw cells onto
the grid. Holding MB2 will draw the background grid color.
o Grid Wrap. Added grid wrapping from left to right and top to bottom.
(Grid edges were originally dead ends.)
o Colors. Added support for setting cell and background colors.
(Original version was black on white only.)
o Profile save. Your current grid size, window position, and colors are
now automatically saved and restored.
Future Enhancements
-------------------
o Templates. I plan to add a "Draw Mode/Templates" switch, probably under
a menu bar "Input" choice. Draw Mode would work like today's
program drawing with MB1 and MB2. Templates mode will let
you select from pre-defined templates of gliders, spaceships,
blocks, etc. and then place them on the grid by clicking MB1.
(Erase with MB2.)
o Game mode. Perhaps a game mode where you try to destroy a spaceship
convoy by hitting it from the side with gliders shot from a
distance (good score would be fewest gliders or fewest
generations until an empty or stable pattern is reached.)
Other game ideas welcome!
o Cut and Paste. Would be nice to be able to cut interesting patterns from
the grid and save them in a template file for later use.
Known Bugs
----------
Minimizing the LIFE window loses your current pattern and results in a message
about there not being enough room for even one cell.
Usual Disclaimer
----------------
This code is, of course, distributed with any explicit or implicit warranties
of any kind. This package, which includes source code, is FreeWare. It may
be freely copied or distributed in its entirety.
Comments or Suggestions
-----------------------
Comments and/or suggestions are welcome. Send them to Internet address:
gnomer@aol.com
-Larry Nomer